package com.tangyuan.user.controller;

import com.tangyuan.common.result.Result;
import com.tangyuan.dto.EnrollRecordDto;
import com.tangyuan.model.User;
import com.tangyuan.model.activity.Enroll;
import com.tangyuan.common.util.CommStatus;
import com.tangyuan.user.service.IEnrollRecordService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: enroll_record
 * @Author: jeecg-boot
 * @Date: 2024-03-20
 * @Version: V1.0
 */
@Api(tags = "enroll_record")
@RestController
@RequestMapping("/user/enrollRecord")
@Slf4j
public class EnrollRecordController {
    @Autowired
    private IEnrollRecordService enrollRecordService;


    /**
     * 报名接口
     *
     * @return
     * @Description:
     */
    @PostMapping("/saveEnroll")
    public Result<Object> saveEnroll(@RequestHeader(name = "Authorization", required = false) String token,
                                     @RequestBody EnrollRecordDto enrollRecordDto) {
        return enrollRecordService.saveEnrollRecord(CommStatus.getUser(token), enrollRecordDto);
    }

    /**
     * 报名详情接口
     */
    @GetMapping("/getEnroll")
    public Result<Object> getEnroll(@RequestHeader(name = "userId", required = false) Long userId,Long activityId) {
        return enrollRecordService.getEnrollListByUserId(userId,activityId);
    }


    /**
     * 拿到报名的票种详情
     */
    @GetMapping("/getEnrollTicketTypeName")
    public Result<Object> getEnrollTicketTypeName(@RequestHeader(name = "userId", required = false) Long userId,Long activityId) {
        return enrollRecordService.getEnrollTicketTypeName(userId,activityId);
    }
}
